home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / ctutor2.zip / ANYFILE.C < prev    next >
C/C++ Source or Header  |  1987-07-04  |  552b  |  23 lines

  1.                                          /* Chapter 10 - Program 7 */
  2. #include "stdio.h"
  3.  
  4. main()
  5. {
  6. FILE *fp1;
  7. char oneword[100],filename[25];
  8. char *c;
  9.  
  10.    printf("Enter filename -> ");
  11.    scanf("%s",filename);         /* read the desired filename */
  12.    fp1 = fopen(filename,"r");
  13.  
  14.    do {
  15.       c = fgets(oneword,100,fp1); /* get one line from the file */
  16.       if (c != NULL)
  17.          printf("%s",oneword);    /* display it on the monitor  */
  18.    } while (c != NULL);          /* repeat until NULL          */
  19.  
  20.    fclose(fp1);
  21. }
  22.  
  23.